package com.fbli.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@Controller
@ResponseBody
public class UpdatePictureController {

    @RequestMapping(value = "/uploadPicture",method = RequestMethod.POST)
    public String uploadPicture(MultipartFile uploadFile) throws IOException {

        String originalFilename = uploadFile.getOriginalFilename();

        uploadFile.transferTo(new File("D:\\IdeaProjects\\gitRepos\\shixun-project\\src\\main\\webapp\\images\\"+originalFilename));

        return "success";
    }
    /*@RequestMapping(value = "/uploadPicture",method = RequestMethod.POST)
    public String uploadFile(MultipartFile imageFile) throws IOException {
        File folder = new File("D:/upload");
        folder.mkdirs();
        String filename = imageFile.getOriginalFilename();
        File file = new File(folder,filename);
        imageFile.transferTo(file);
        return "success";
    }*/


}
